package com.admin.business.venusOrganizeEmployee;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.tiangong.framework.annotation.OpenApi;
import com.tiangong.framework.bo.CDO;
import com.tiangong.framework.bo.Return;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 员工信息表
 * @create: 2022-03-22 18:46:06
 **/
@DS("user")
@Service("venusOrganizeEmployee")
@Slf4j
public class VenusOrganizeEmployeeService{

    @Resource
    VenusOrganizeEmployeeDao venusOrganizeEmployeeDao;

    /**
     * 添加员工信息表,获取employee_id数据
     *
     * @param cdoRequest - employee_id:
     *                   - employee_logo:员工头像
     *                   - sys_user_id:管理系统用户id
     *                   - employee_code:员工编码
     *                   - employee_org_id:企业id
     *                   - employee_mobile:员工手机号
     *                   - employee_name:员工姓名
     *                   - employee_sex:性别（1、男 2、女）
     *                   - employee_org_dept_id:部门id
     *                   - employee_org_post_id:岗位id
     *                   - employee_card_infront:用户身份证正面
     *                   - employee_card_behind:用户身份证反面
     *                   - employee_card_code:用户身份证号
     *                   - employee_contract_id:合同类型id
     *                   - employee_info:审核结果说明
     *                   - employee_month_num:试用期月数
     *                   - employee_project_id:项目id
     *                   - employee_try_money:试用期薪资
     *                   - employee_post_work_time:入职时间
     *                   - employee_clock_code:绑定员工唯一电脑打卡
     *                   - employee_birth_date:出生日期
     *                   - employee_working_years:工龄
     *                   - employee_state:员工状态（1 正常 2 禁用 3删除）
     *                   - employee_status:员工状态（0 不限 1 在职 2 离职 3 停职）
     *                   - employee_native_place:籍贯
     *                   - employee_nation:民族
     *                   - employee_marriage:婚姻
     *                   - employee_politics_status:政治面貌
     *                   - employee_urgency_person:紧急联系人
     *                   - employee_pay_card_number:工资卡号
     *                   - employee_create_bank:开户银行
     *                   - employee_house_place:户口所在地
     *                   - employee_household_type:户口类型
     *                   - employee_now_place:现住址
     *                   - employee_height:身高
     *                   - employee_weight:体重
     *                   - employee_blood_type:血型
     *                   - employee_heath:健康
     *                   - employee_try_start_time:适用开始时间
     *                   - employee_try_end_time:试用结束时间
     *                   - employee_contract_start_time:合同开始时间
     *                   - employee_contract_end_time:合同结束时间
     *                   - employee_from:员工来源
     *                   - employee_school_name:学校名称
     *                   - employee_profession:所学专业
     *                   - employee_education:学历
     *                   - employee_study_time:学习时间
     *                   - employee_study_end_time:毕业时间
     *                   - employee_email:员工电子邮箱
     *                   - employee_com_level:计算机等级
     *                   - employee_english_level:英语水平
     *                   - employee_work_time:工作经验
     *                   - employee_month_salary:月薪
     *                   - employee_prove_person:证明人
     *                   - employee_prove_tel:证明人电话
     *                   - employee_secrecy_agreement:保密协议
     *                   - employee_social_security:社保缴纳情况(1、已缴纳 2、未缴纳 3、转入 4、转出)
     *                   - employee_last_department:上家部门
     *                   - employee_last_post:上家岗位
     *                   - employee_start_post_time:上岗时间
     *                   - employee_leave_post_time:离职日期
     *                   - employee_leave_cause:离职原因
     *                   - employee_self_evaluation:自我评价
     *                   - employee_education_photo:学历照片
     *                   - employee_province:省
     *                   - employee_city:市
     *                   - employee_district:区
     *                   - employee_create_time:创建时间
     *                   - employee_contract_status:合同状态（0 不限、1 未签，2 已签，3 待签、4 过期）
     *                   - employee_age:年龄
     *                   - employee_post_properties:岗位性质（0 不限1 全职 2 兼职）
     *                   - employee_marriage_status:婚姻状态（0 不限、1 未婚，2 已婚，3 离异，4 丧偶，5 保密）
     *                   - employee_excellent:1代表优秀员工
     * @return
     * @author ht
     * @create: 2022-03-22 18:46:06
     */
    @OpenApi
    public Return addVenusOrganizeEmployee(CDO cdoRequest) {
        venusOrganizeEmployeeDao.addVenusOrganizeEmployee(cdoRequest);
        CDO cdoResult = new CDO();
        if (cdoRequest.containsKey("employee_id")) {
            cdoResult.set("employee_id", cdoRequest.get("employee_id"));
        }
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据employee_id，更新员工信息表数据
     *
     * @param cdoRequest - employee_id:
     *                   - employee_logo:员工头像
     *                   - sys_user_id:管理系统用户id
     *                   - employee_code:员工编码
     *                   - employee_org_id:企业id
     *                   - employee_mobile:员工手机号
     *                   - employee_name:员工姓名
     *                   - employee_sex:性别（1、男 2、女）
     *                   - employee_org_dept_id:部门id
     *                   - employee_org_post_id:岗位id
     *                   - employee_card_infront:用户身份证正面
     *                   - employee_card_behind:用户身份证反面
     *                   - employee_card_code:用户身份证号
     *                   - employee_contract_id:合同类型id
     *                   - employee_info:审核结果说明
     *                   - employee_month_num:试用期月数
     *                   - employee_project_id:项目id
     *                   - employee_try_money:试用期薪资
     *                   - employee_post_work_time:入职时间
     *                   - employee_clock_code:绑定员工唯一电脑打卡
     *                   - employee_birth_date:出生日期
     *                   - employee_working_years:工龄
     *                   - employee_state:员工状态（1 正常 2 禁用 3删除）
     *                   - employee_status:员工状态（0 不限 1 在职 2 离职 3 停职）
     *                   - employee_native_place:籍贯
     *                   - employee_nation:民族
     *                   - employee_marriage:婚姻
     *                   - employee_politics_status:政治面貌
     *                   - employee_urgency_person:紧急联系人
     *                   - employee_pay_card_number:工资卡号
     *                   - employee_create_bank:开户银行
     *                   - employee_house_place:户口所在地
     *                   - employee_household_type:户口类型
     *                   - employee_now_place:现住址
     *                   - employee_height:身高
     *                   - employee_weight:体重
     *                   - employee_blood_type:血型
     *                   - employee_heath:健康
     *                   - employee_try_start_time:适用开始时间
     *                   - employee_try_end_time:试用结束时间
     *                   - employee_contract_start_time:合同开始时间
     *                   - employee_contract_end_time:合同结束时间
     *                   - employee_from:员工来源
     *                   - employee_school_name:学校名称
     *                   - employee_profession:所学专业
     *                   - employee_education:学历
     *                   - employee_study_time:学习时间
     *                   - employee_study_end_time:毕业时间
     *                   - employee_email:员工电子邮箱
     *                   - employee_com_level:计算机等级
     *                   - employee_english_level:英语水平
     *                   - employee_work_time:工作经验
     *                   - employee_month_salary:月薪
     *                   - employee_prove_person:证明人
     *                   - employee_prove_tel:证明人电话
     *                   - employee_secrecy_agreement:保密协议
     *                   - employee_social_security:社保缴纳情况(1、已缴纳 2、未缴纳 3、转入 4、转出)
     *                   - employee_last_department:上家部门
     *                   - employee_last_post:上家岗位
     *                   - employee_start_post_time:上岗时间
     *                   - employee_leave_post_time:离职日期
     *                   - employee_leave_cause:离职原因
     *                   - employee_self_evaluation:自我评价
     *                   - employee_education_photo:学历照片
     *                   - employee_province:省
     *                   - employee_city:市
     *                   - employee_district:区
     *                   - employee_create_time:创建时间
     *                   - employee_contract_status:合同状态（0 不限、1 未签，2 已签，3 待签、4 过期）
     *                   - employee_age:年龄
     *                   - employee_post_properties:岗位性质（0 不限1 全职 2 兼职）
     *                   - employee_marriage_status:婚姻状态（0 不限、1 未婚，2 已婚，3 离异，4 丧偶，5 保密）
     *                   - employee_excellent:1代表优秀员工
     * @return
     * @author ht
     * @create: 2022-03-22 18:46:06
     */
    @OpenApi
    public Return updateVenusOrganizeEmployeeById(CDO cdoRequest) {
        int affectedRows = venusOrganizeEmployeeDao.updateVenusOrganizeEmployeeById(cdoRequest);
        CDO cdoResult = new CDO();
        cdoResult.set("affectedRows", affectedRows);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据employee_id，删除员工信息表数据
     *
     * @param cdoRequest - employee_id:
     * @return
     * @author ht
     * @create: 2022-03-22 18:46:06
     */
    @OpenApi
    public Return deleteVenusOrganizeEmployeeById(CDO cdoRequest){
        int affectedRows = venusOrganizeEmployeeDao.deleteVenusOrganizeEmployeeById(cdoRequest.getLong("employee_id"));
        CDO cdoResult = new CDO();
        cdoResult.set("affectedRows", affectedRows);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据条件，删除员工信息表数据
     *
     * @param cdoRequest - sys_user_id:管理系统用户id
     *                   - employee_code:员工编码
     *                   - employee_org_id:企业id
     *                   - employee_org_dept_id:部门id
     *                   - employee_org_post_id:岗位id
     *                   - employee_card_code:用户身份证号
     *                   - employee_project_id:项目id
     *                   - employee_education:学历
     *                   - employee_post_properties:岗位性质（0 不限1 全职 2 兼职）
     *                   - employee_excellent:1代表优秀员工
     * @return
     * @author ht
     * @create: 2022-03-22 18:46:06
     */
    @OpenApi
    public Return deleteVenusOrganizeEmployee(CDO cdoRequest) {
        int affectedRows = venusOrganizeEmployeeDao.deleteVenusOrganizeEmployee(cdoRequest);
        CDO cdoResult = new CDO();
        cdoResult.set("affectedRows", affectedRows);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据ID，获取员工信息表数据
     *
     * @param cdoRequest - employee_id:
     * @return
     * @author ht
     * @create: 2022-03-22 18:46:06
     */
    @OpenApi
    public Return getVenusOrganizeEmployeeById(CDO cdoRequest) {
        CDO cdoMapperResult = venusOrganizeEmployeeDao.getVenusOrganizeEmployeeById(cdoRequest.getLong("employee_id"));
        return Return.valueOf(cdoMapperResult);
    }

    /**
     * 根据混合条件，获取员工信息表数据
     *
     * @param cdoRequest - employee_id:
     *                   - sys_user_id:管理系统用户id
     *                   - employee_code:员工编码
     *                   - employee_org_id:企业id
     *                   - employee_org_dept_id:部门id
     *                   - employee_org_post_id:岗位id
     *                   - employee_card_code:用户身份证号
     *                   - employee_project_id:项目id
     *                   - employee_education:学历
     *                   - employee_post_properties:岗位性质（0 不限1 全职 2 兼职）
     *                   - employee_excellent:1代表优秀员工
     * @return
     * @author ht
     * @create: 2022-03-22 18:46:06
     */
    @OpenApi
    public Return getVenusOrganizeEmployee(CDO cdoRequest) {
        CDO cdoMapperResult = venusOrganizeEmployeeDao.getVenusOrganizeEmployee(cdoRequest);
        return Return.valueOf(cdoMapperResult);
    }

    /**
     * 根据非空条件，获取员工信息表数据列表
     *
     * @param cdoRequest - sys_user_id:管理系统用户id
     *                   - employee_code:员工编码
     *                   - employee_org_id:企业id
     *                   - employee_org_dept_id:部门id
     *                   - employee_org_post_id:岗位id
     *                   - employee_card_code:用户身份证号
     *                   - employee_project_id:项目id
     *                   - employee_education:学历
     *                   - employee_post_properties:岗位性质（0 不限1 全职 2 兼职）
     *                   - employee_excellent:1代表优秀员工
     * @return
     * @author ht
     * @create: 2022-03-22 18:46:06
     */
    @OpenApi
    public Return getVenusOrganizeEmployeeList(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.containsKey("pageIndex") ? cdoRequest.getInteger("pageIndex") : 0;
        int recordSize = cdoRequest.containsKey("recordSize") ? cdoRequest.getInteger("recordSize") : 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusOrganizeEmployeeDao.getVenusOrganizeEmployeeList(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusOrganizeEmployeeDao.getVenusOrganizeEmployeeListCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }

    /**
     * 根据混合条件，获取员工信息表数据列表
     *
     * @param cdoRequest - employee_id:
     *                   - sys_user_id:管理系统用户id
     *                   - employee_code:员工编码
     *                   - employee_org_id:企业id
     *                   - employee_org_dept_id:部门id
     *                   - employee_org_post_id:岗位id
     *                   - employee_card_code:用户身份证号
     *                   - employee_project_id:项目id
     *                   - employee_education:学历
     *                   - employee_post_properties:岗位性质（0 不限1 全职 2 兼职）
     *                   - employee_excellent:1代表优秀员工
     * @return
     * @author ht
     * @create: 2022-03-22 18:46:06
     */
    @OpenApi
    public Return getVenusOrganizeEmployeeListByCondition(CDO cdoRequest) {
        Integer pageIndex = cdoRequest.containsKey("pageIndex") ? cdoRequest.getInteger("pageIndex") : 0;
        int recordSize = cdoRequest.containsKey("recordSize") ? cdoRequest.getInteger("recordSize") : 10;
        cdoRequest.set("recordFrom", pageIndex * recordSize);
        cdoRequest.set("recordSize", recordSize);
        List<CDO> cdoMapperResultList = venusOrganizeEmployeeDao.getVenusOrganizeEmployeeListByCondition(cdoRequest);
        boolean isEndPage = false;
        if (cdoMapperResultList.size() < recordSize) {
            isEndPage = true;
        }
        CDO cdoResult = new CDO();
        cdoResult.set("isEndPage", isEndPage);
        cdoResult.set("datalist", cdoMapperResultList);
//        int total = venusOrganizeEmployeeDao.getVenusOrganizeEmployeeListByConditionCount(cdoRequest);
//        cdoResult.set("total", total);
        return Return.valueOf(cdoResult);
    }
}
